package com.copa.module.goods.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.copa.domain.ResponseDto;
import com.copa.module.goods.domain.dto.CategoryListDto;
import com.copa.module.goods.mapper.CategoryDao;
import com.copa.module.goods.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author copa
 * @createDate 2021-01-14 9:26
 * @function
 */
@Service
public class CategoryServiceImpl implements CategoryService {

    @Autowired
    private CategoryDao categoryDao;

    @Override
    public ResponseDto<List<CategoryListDto>> indexList() {
        List<CategoryListDto> categoryListDtos = categoryDao.indexList();
        if (ObjectUtil.isNotEmpty(categoryListDtos)
                && ObjectUtil.length(categoryListDtos) > 0) {
            return ResponseDto.success(categoryListDtos);
        }
        return ResponseDto.errorMsg("没有查找到类目！");
    }

    @Override
    public ResponseDto<List<CategoryListDto>> list() {
        List<CategoryListDto> categoryListDtos = categoryDao.list();
        if (ObjectUtil.isNotEmpty(categoryListDtos)
                && ObjectUtil.length(categoryListDtos) > 0) {
            return ResponseDto.success(categoryListDtos);
        }
        return ResponseDto.errorMsg("没有查找到类目！");
    }
}
